var app = getApp();
var util = require("../../utils/libs.js")
var api = require("../../utils/api.js")
Page({
  data: {
     itemList:["接龙故事","我出的题","我的邀请"],
     skillList:[ ],
     uid:"",
     page:1,
     limit:10,
     skillid:null
  },
  getBuild(){
    let that =this
    that.setData({
     skillid:1      
    })
    util.request(api.buildList,{
      page:that.data.page,
      limit:that.data.limit,
      uid:that.data.uid
    },"GET")
    .then(function (res) {
      if(res.error_code === 0){
            that.setData({
              skillList:res.data.list
            })
      }
    })
  },
  gettopicList(){
    let that =this
    that.setData({
      skillid:2     
     })
    util.request(api.topicList,{
      page:that.data.page,
      limit:that.data.limit,
      uid:that.data.uid
    },"GET")
    .then(function (res) {
      if(res.error_code === 0){
            that.setData({
              skillList:res.data.list
          })
      }
    })
  },
  getarticleList(){
    let that = this
    that.setData({
      skillid:3      
     })
    util.request(api.articleLists,{
      page:that.data.page,
      limit:that.data.limit,
      uid:that.data.uid
    },"GET")
    .then(function (res) {
      if(res.error_code === 0){
        console.log(res)
            that.setData({
              skillList:res.data.list
      })
      }
    })
  },
  onLoad (options) {
    let that = this
    // 页面初始化 options为页面跳转所带来的参数
    let uid = wx.getStorageSync('uid')
    that.setData({
      uid:uid
    })
    that.getBuild()
  },
  goDetail(e){
   let that = this 
   let idType = that.data.skillid
   let id = e.currentTarget.dataset.id
   if(idType == 1){
    wx.navigateTo({
      url:"/pages/listdetais/listdetais?id="+id
    })
   }else if(idType == 2){
    wx.navigateTo({
      url:"/pages/writing/writing?id="+id
    })
   }else if(idType == 3){
    wx.navigateTo({
      url:"/pages/assist/assist?id="+id
    })
   }
  },
  onReady () {
    // 页面渲染完成
  },
  onShow () {
    // 页面显示
  },
  onHide () {
    // 页面隐藏

  },
  onUnload () {
    // 页面关闭

  }
})
